﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Nachos.Stats
{
    public class Statistics 
    {
        /// <summary>
        /// Total time running Nachos
        /// </summary>
        public int TotalTicks { get; set; }
        /// <summary>
        /// Time spent idle (no threads to run)
        /// </summary>
        public int IdleTicks { get; set; }
        /// <summary>
        /// Time spent executing system code
        /// </summary>
        public int SystemTicks { get; set; }
        /// <summary>
        /// Time spent executing user code
        /// (this is also equal to # of
        /// user instructions executed)
        /// </summary>
        public int UserTicks { get; set; }
        /// <summary>
        /// number of disk read requests
        /// </summary>
        public int NumberOfDiskReads { get; set; }
        /// <summary>
        /// number of disk write requests
        /// </summary>
        public int NumberOfDiskWrites { get; set; } 
        /// <summary>
        /// number of characters read from the keyboard
        /// </summary>
        public int NumberOfConsoleCharactersRead { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int NumberOfConsoleCharactersWritten { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public int NumberOfPageFaults { get; set; }
        /// <summary>
        /// number of packets sent over the network
        /// </summary>
        public int NumberOfPacketsSent { get; set; }
        /// <summary>
        /// number of packets received over the network
        /// </summary>
        public int NumberOfPacketsReceived { get; set; }

        public Statistics() 		// initialize everything to zero
        {
            TotalTicks = IdleTicks = SystemTicks = UserTicks = 0;
            NumberOfDiskReads = NumberOfDiskWrites = 0;
            NumberOfConsoleCharactersRead = NumberOfConsoleCharactersWritten = 0;
            NumberOfPageFaults = NumberOfPacketsSent = NumberOfPacketsReceived = 0;
        }
        /// <summary>
        /// Print collected statistics
        /// </summary>
        public void Print() 
        { 
        }
        // Constants used to reflect the relative time an operation would
        // take in a real system.  A "tick" is a just a unit of time -- if you 
        // like, a microsecond.
        //
        // Since Nachos kernel code is directly executed, and the time spent
        // in the kernel measured by the number of calls to enable interrupts,
        // these time constants are none too exact.

        public const int UserTick = 	   1;	// advance for each user-level instruction 
        public const int SystemTick =	  10; 	// advance each time interrupts are enabled
        public const int RotationTime = 500; 	// time disk takes to rotate one sector
        public const int SeekTime =	 500;  	// time disk takes to seek past one track
        public const int ConsoleTime =	 100;	// time to read or write one character
        public const int NetworkTime =	 100;  	// time to send or receive one packet
        public const int TimerTicks = 	 100;  	// (average) time between timer interrupts
    }
}